<?php
    include_once('Configs/database.php');
    include_once('LopHocPhan.php');
    class HocPhan extends database{
        private $mahp;
        private $tenhp;
        private $sotc;
		private $sotietlithuyet;
        private $sotietthuchanh;
        private $manhom;
        
        private $thongtingv;
        private $hptienquyet;
        private $muctieu;
        private $ppgiangday;
        private $danhgiahp;        
        private $tailieuthamkhao;
        //private $dsdecuonghpchitiet;//kieu DeCuongHPChiTiet
        private $tenfile;
        public function setMaHP($mahp){
            $this->mahp = $mahp;
        }
		public function getMaHP(){
            return $this->mahp;
        }
		
        public function setTenHP($tenhp){
            $this->tenhp = $tenhp;
        }
		public function getTenHP(){
            return $this->tenhp;
        }
		
        public function setSoTC($sotc){
            $this->sotc = $sotc;
        }
       
        
        public function getSoTC(){
            return $this->sotc;
        }
		
		public function setSoTietLiThuyet($sotietlithuyet){
            $this->sotietlithuyet = $sotietlithuyet;
        }
		public function getSoTietLiThuyet(){
            return $this->sotietlithuyet;
        }
		
        public function setSoTietThucHanh($sotietthuchanh){
            $this->sotietthuchanh = $sotietthuchanh;
        }
		public function getSoTietThucHanh(){
            return $this->sotietthuchanh;
        }
		
		public function setMaNhom($manhom){
            $this->manhom= $manhom;
        }
		public function getMaNhom(){
            return $this->manhom;
        }
        
		public function setThongTinGV($thongtingv){
            $this->thongtingv = $thongtingv;
        }
        public function getThongTinGV(){
            return $this->thongtingv;
        }
        
        public function setHPTienQuyet($hptienquyet){
            $this->hptienquyet = $hptienquyet;
        }
        public function getHPTienQuyet(){
            return $this->hptienquyet;
        }
        
        public function setMucTieu($muctieu){
            $this->muctieu = $muctieu;
        }
        public function getMucTieu(){
            return $this->muctieu;
        }
        
        public function setPPGiangDay($ppgiangday){
            $this->ppgiangday = $ppgiangday;
        }
        public function getPPGiangDay(){
            return $this->ppgiangday;
        }
        
        public function setDanhGiaHP($danhgiaHP){
            $this->danhgiahp = $danhgiaHP;
        }
        public function getDanhGiaHP(){
            return $this->danhgiahp;
        }
        
        public function setTaiLieuThamKhao($tailieuthamkhao){
            $this->tailieuthamkhao = $tailieuthamkhao;
        }
        public function getTaiLieuThamKhao(){
            return $this->tailieuthamkhao;
        }
        
        public function setTenFile($tenfile){
            $this->tenfile = $tenfile;
        }
        public function getTenFile(){
            return $this->tenfile;
        }
        
        
       
        
        
        
        public function thongtinHP(){
            $this->setQuery("select * from HocPhan where mahp='".$this->getMaHP()."'");
             
            return $this->fetchAll();
            
            
        }
         public function thongtinDeCuongHP(){
            $query = "select a.mahp, tenhp, sotc,sotietlithuyet,sotietthuchanh,thongtingv,
						hptienquyet,muctieu,ppgiangday,danhgiahp,tailieuthamkhao,tenfile,tenkhoa ";
            $query .= "from HocPhan a, ChuongTrinhDaoTao b, NganhHoc c, Khoa d ";
            $query .= "where a.mahp='".$this->getMaHP()."' and a.mahp = b.mahp and b.manganh = c.manganh and c.makhoa = d.makhoa";
            //$this->setQuery("select * from DeCuongHocPhan a, HocPhan b, NganhHoc c, Khoa d where  a.mahp='".$this->getMaHP()."' and a.manganh='".$this->getMaNganh()."' and a.mahp = b.mahp and a.manganh = c.manganh and c.makhoa=d.makhoa");
            $this->setQuery($query);
            return $this->fetchAll();
         }
        public function themHP(){
            $query = "insert into HocPhan(mahp,tenhp,sotc,sotietlithuyet,sotietthuchanh,manhom, thongtingv, hptienquyet,muctieu,ppgiangday,danhgiahp,tailieuthamkhao,tenfile) ";
            $query .= "values ('".$this->getMaHP()."','".$this->getTenHP()."',".$this->getSoTC().",".$this->getSoTietLiThuyet().",".$this->getSoTietThucHanh().", ";
            $query .= "".$this->getMaNhom().",'".$this->getThongTinGV()."','".$this->getHPTienQuyet()."','".$this->getMucTieu()."','".$this->getPPGiangDay()."','".$this->getDanhGiaHP()."','".$this->getTaiLieuThamKhao()."','".$this->getTenFile()."')";
            //$this->setQuery("insert into HocPhan(mahp,tenhp,sotc,sotietlithuyet,sotietthuchanh,manhom, thongtingv, hptienquyet,muctieu,ppgiangday,danhgiahp,tailieuthamkhao,tenfile) values ('".$this->getMaHP()."','".$this->getTenHP()."',".$this->getSoTC().",".$this->getSoTietLiThuyet().",".$this->getSoTietThucHanh().",'".$this->getMaNhom()."')");
            $this->setQuery($query);
             //echo $this->getQuery();
            return $this->executeQuery();
        }
        public function suaHP(){
            $query = "update HocPhan set tenhp='".$this->getTenHP()."',sotc=".$this->getSoTC().",sotietlithuyet=".$this->getSoTietLiThuyet().", ";
            $query .= "sotietthuchanh=".$this->getSoTietThucHanh().",manhom=".$this->getMaNhom().", thongtingv='".$this->getThongTinGV()."', ";
            $query .= "hptienquyet='".$this->getHPTienQuyet()."',muctieu='".$this->getMucTieu()."',ppgiangday='".$this->getPPGiangDay()."', ";
            $query .= "danhgiahp='".$this->getDanhGiaHP()."',tailieuthamkhao='".$this->getTaiLieuThamKhao()."',tenfile='".$this->getTenFile()."' where mahp='".$this->getMaHP()."'";
            
            //$this->setQuery("update HocPhan set tenhp='".$this->getTenHP()."', sotc=".$this->getSoTC().",sotietlithuyet=".$this->getSoTietLiThuyet().",sotietthuchanh=".$this->getSoTietThucHanh().",manhom='".$this->getMaNhom()."' where mahp='".$this->getMaHP()."'");
            $this->setQuery($query);
            //echo $this->getQuery();
            return $this->executeQuery();
        }
        public function xoaHP(){
            $this->setQuery("delete from HocPhan where mahp='".$this->getMaHP()."'");
            return $this->executeQuery();
        }
        public function dsDeCuongHPChiTiet(){
            $this->setQuery("select madc,noidungvt,noidung,sotiet,ghichu,mahp from DeCuongHPChiTiet where mahp = '".$this->getMaHP()."' order by madc asc");
            return $this->fetchAll();
        }
        public function tongSoTietCuaDCCT(){
			$query = "select sum(sotiet) as tongsotiet from DeCuongHPChiTiet where mahp='".$this->getMaHP()."' group by mahp";
			$this->setQuery($query);
			$resulttongsotiet = $this->fetchAll();
			$rowstongsotiet = mysql_fetch_array($resulttongsotiet);
			$tongsotiet = $rowstongsotiet['tongsotiet'];
			return $tongsotiet;
		}
        /*public function dsDeCuongHPChiTiet(){
            $decuongct= new DeCuongHPChiTiet();
            return $decuongct->dsDeCuongCTTheoNganhHP($this->getMaHP());
        }
        
        
        public function dsHPDuKienMoTrongHKNH($namhoc,$hocki){
             $this->setQuery("select * from HocPhan a, DuKienMoVao b where a.mahp=b.mahp and namhoc='".$namhoc."' and hocki=".$hocki."");
             return $this->fetchAll();
        }
        public function dsTatCaHP(){
            $this->setQuery("select * from HocPhan order by tenhp asc");
            return $this->fetchAll();
        }
        public function dsLopHP(){
            $this->setQuery("select * from LopHocPhan where mahp='".$this->getMaHP()."'");
            return $this->fetchAll();
        }
        public function dsLopHPMoTrongHKNH($hocki,$namhoc){
            $lophp = new LopHocPhan();
            $lophp->setMaHP($this->getMaHP());
            $lophp->setHocKi($hocki);
            $lophp->setNamHoc($namhoc);
            return $lophp->dsLopHPMoTrongHKNHCuaHP();
            
        }*/
		
    }
?>